
#ifndef __METAGRAPH_H__
#define __METAGRAPH_H__

#include "basetype.h"
#include <windows.h>
#include "3dDef.h"

class CMetaGraph
{
public:

	CMetaGraph()
	{
		m_pBuffer = NULL;
		memset(&m_clipRect, 0, sizeof(m_clipRect));
	}

	int Init(uint8 * pBuffer, int	lpitch, RECT clipRect)
	{
		m_pBuffer	= pBuffer;
		m_lpitch	= lpitch;
		m_clipRect	= clipRect;

		return 0;
	}

	virtual ~CMetaGraph()
	{

	}

protected:

	uint8 *		m_pBuffer;
	int			m_lpitch;
	RECT		m_clipRect;
};

//
class CGraphLine : public CMetaGraph
{
public:
	
	CGraphLine()
	{

	}

	virtual ~CGraphLine()
	{

	}

	int Draw_Line16(int x0,int y0, int x1, int y1, int color, BOOL bClip = TRUE);
	int Draw_Line(int x0,int y0, int x1, int y1, int color, BOOL bClip = TRUE);


protected:

	int Draw_Line16_Imp(int x0, int y0, // starting position 
						int x1, int y1, // ending position
						int color);		// color index

	int Draw_Line_Imp(	int x0, int y0, // starting position 
						int x1, int y1, // ending position
						int color);		// color index

	int Clip(int &x1,int &y1,int &x2, int &y2);

	//
};

class CGraphTrig : public CMetaGraph
{
public:
	CGraphTrig()
	{
	}
	
	virtual ~CGraphTrig()
	{
	}


	//
	int Draw_Top_Tri(	int x1,int y1, 
						int x2,int y2, 
						int x3,int y3,
						int color);

	int Draw_Bottom_Tri(int x1,int y1, 
								int x2,int y2, 
								int x3,int y3,
								int color);

	int Draw_Top_Tri16(	int x1,int y1, 
						int x2,int y2, 
						int x3,int y3,
						int color);

	int Draw_Bottom_Tri16(	int x1,int y1, 
							int x2,int y2, 
							int x3,int y3,
							int color);

	int Draw_TrigFP_2D(	int x1,int y1,
						int x2,int y2,
						int x3,int y3,
						int color);

	int Draw_Trig_2D(	int x1,int y1,
						int x2,int y2,
						int x3,int y3,
						int color);

	int Draw_Trig_2D16(	int x1,int y1,
						int x2,int y2,
						int x3,int y3,
						int color);

	int Draw_Top_TriFP(	int x1,int y1,
						int x2,int y2, 
						int x3,int y3,
						int color);

	int Draw_Bottom_TriFP(	int x1,int y1, 
							int x2,int y2, 
							int x3,int y3,
							int color);
	//


	//
	int Draw_Trig_2D2(	float x1,float y1,
						float x2,float y2,
						float x3,float y3,
						int color );

	int Draw_Trig_2D2_16(	float x1,float y1,
							float x2,float y2,
							float x3,float y3,
							int color);

	int Draw_Top_Tri2(	float x1,float y1, 
						float x2,float y2, 
						float x3,float y3,
						int color);

	int Draw_Top_Tri2_16(	float x1, float y1, 
							float x2, float y2, 
							float x3, float y3,
							int color);

	int Draw_Bottom_Tri2(	float x1,float y1, 
							float x2,float y2, 
							float x3,float y3,
							int color);
		
	int Draw_Bottom_Tri2_16(float x1, float y1, 
							float x2, float y2, 
							float x3, float y3,
							int color);
protected:

};

#endif